<?php 

/**
* 数据库操作类
*/
class Model 
{
	public $table;
	public $db;
	function __construct($table=null)
	{
		if($table){
			$this->table=$table;
		}

		try{
			$this->db = new PDO("mysql:host=".C('db_host').";dbname=".C('db_dbname').";charset=utf8",C('db_user'),C('db_password'));
			
		}catch(PDOException  $e ){
			echo "Error: ".$e;exit;
		}
	}
	public function query($sql)
	{
		$res = $this->db->query($sql);

		if(!$res){
			echo "执行失败：错误代码：".$this->db->errorCode()."错误信息：".$this->db->errorInfo()[2];
		}

		return $res->fetchAll(PDO::FETCH_ASSOC);
	}

	public function delete($where)
	{
		$sql = "delete from ".$this->table." where ".$where;

		var_dump($sql);
		$res = $this->db->query($sql);

	}
}











 ?>